package com.hannesdorfmann.mosby3.mvi.integrationtest.lifecycle.fraction;

import com.hannesdorfmann.mosby3.mvi.MviFraction;
import com.hannesdorfmann.mosby3.mvi.integrationtest.ResourceTable;
import com.hannesdorfmann.mosby3.mvi.integrationtest.lifecycle.LifecycleTestPresenter;
import com.hannesdorfmann.mosby3.mvi.integrationtest.lifecycle.LifecycleTestView;

public class MviFinishOnActiveFraction extends MviFraction<LifecycleTestView, LifecycleTestPresenter> implements LifecycleTestView {


    public static volatile LifecycleTestPresenter presenter;
    public static int presenterCreatedCount;


    @Override
    protected int getUIContent() {
        return ResourceTable.Layout_fraction_mvi;
    }

    @Override
    protected void initCompoment() {

    }

    @Override
    public LifecycleTestPresenter createPresenter() {
        presenter = getPresenterInstance();
        presenterCreatedCount++;
        return presenter;
    }

    public static LifecycleTestPresenter getPresenterInstance(){
        if(MviFinishOnActiveFraction.presenter == null){
            MviFinishOnActiveFraction.presenter = new LifecycleTestPresenter();
        }
        return  MviFinishOnActiveFraction.presenter;
    }

    @Override
    protected void onActive() {
        super.onActive();
        terminateAbility();
    }

}
